package GUI;
/**
 * principles view checked assigment screen for view student academic personal data
 */

import java.awt.Dimension;
import java.awt.GridLayout;
import javax.swing.JPanel;
import javax.swing.JLabel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JButton;


public class ParentViewCheckedAssignmentScreen extends JPanel {
   
	
	
	
    private JLabel lblViewAcademicData = null;
	private JButton btnBack = null;
	private Dimension defaultDim=null;
	private JScrollPane scrollPane=null;
	public String[][]data = null;
	public ParentMainMenu pmn = null;
	public Login myLoginFrame = null;
	public UserParent user = null;
    private int index = 0;
	private  JTable dataTable_1=null;
	private String IsExceptional = "Exceptional request approved";
 
    public ParentViewCheckedAssignmentScreen(ParentMainMenu pmn) {
    	
        super(new GridLayout(1,0));
        index=pmn.user.getIndex();
        String[] columnNamesStr = {"Grade","Assignment"};
        data = new String[pmn.user.StudentsData.get(index).ListOfCourses.lOfCourses.size()][2];
    	
    	for(int i=0, j=0,count=0;i<pmn.user.StudentsData.get(index).ListOfCourses.lOfCourses.size();i++)
    	{
    	/*if((stmn.user.getYear().equals((stmn.user.StudentData.ListOfCourses.lOfCourses.get(i).getYear().toString())))&&
    		(stmn.user.getSem().equals(stmn.user.StudentData.ListOfCourses.lOfCourses.get(i).getSemester().toString())&&
    		(stmn.user.getCourse().endsWith(stmn.user.StudentData.ListOfCourses.lOfCourses.get(i).getCid().toString()))))*/
    			
    	{
    		 data[count][j]=null;//get assignment grade from the DB that the teacher updated   
    		 data[count][j+1]=null;//Link to the file that the teacher checked and wrote her comments in the assignment file itself
    		 
    		 count++;
    	}	
    	 //System.out.println(stmn.user.StudentData.ListOfCourses.lOfCourses.size());
    	// System.out.println(stmn.user.StudentData.ListOfCourses.lOfCourses.get(i).getCid().toString());
    	
    	// System.out.println(stmn.user.StudentData.ListOfCourses.lOfCourses.get(i).getCname().toString());
    	// System.out.println(stmn.user.StudentData.ListOfCourses.lOfCourses.get(i).getGrade().toString());
    	// System.out.println(stmn.user.StudentData.ListOfCourses.lOfCourses.get(i).getYear().toString());
    	// System.out.println(stmn.user.StudentData.ListOfCourses.lOfCourses.get(i).getSemester().toString());
    	// System.out.println(stmn.user.StudentData.ListOfCourses.lOfCourses.get(i).getIsExeptional().toString());
    	 
    	
    	}
 
         
        final JTable table = new JTable(data, columnNamesStr);
        table.setPreferredScrollableViewportSize(new Dimension(500, 500));
        table.setFillsViewportHeight(true);
        printDebugData(table);
      
        
      
 
        //Create the scroll pane and add the table to it.
        JScrollPane scrollPane = new JScrollPane(table);
 
        //Add the scroll pane to this panel.
        add(scrollPane);
        
    }
 
    private void printDebugData(JTable table) {
        int numRows = table.getRowCount();
        int numCols = table.getColumnCount();
        javax.swing.table.TableModel model = table.getModel();
 
        System.out.println("Value of data: ");
        for (int i=0; i < numRows; i++) {
            System.out.print("    row " + i + ":");
            for (int j=0; j < numCols; j++) {
                System.out.print("  " + model.getValueAt(i, j));
            }
            System.out.println();
        }
        System.out.println("--------------------------");
    }
 
   
}




